/*
 * @lc app=leetcode.cn id=137 lang=cpp
 *
 * [137] 只出现一次的数字 II
 */

// @lc code=start
class Solution
{
public:
  int singleNumber(vector<int>& nums)
  {
    unordered_map<int, int> m;
    for (int& num : nums)
      m[num]++;
    for (auto itr = m.begin(); itr != m.end(); ++itr) {
      if (itr->second == 1)
        return itr->first;
    }
    return -1; // unreachable
  }
};
// @lc code=end
